#include <bits/stdc++.h>
using namespace std;

int ans[10000];
int temp[10000];

int main()
{
    int n, m, t;
    cin >> n >> m >> t;
    for (int i = 1; i <= n * m; i++)
    {
        cin >> ans[i];
    }

    while (t--)
    {
        int op, a, b;
        cin >> op >> a >> b;
        if (op == 1)
        {
            n = a, m = b;
            /* for (int i = 1; i <= n * m; i++)
            {
                cout << ans[i] << " ";
                if (i % m == 0)
                {
                    cout << endl;
                }
            }
            // cout << endl; */
        }
        else if (op == 2)
        {
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= m; j++)
                {
                    temp[(j - 1) * n + i] = ans[(i - 1) * m + j];
                }
            }
            for (int i = 1; i <= n * m; i++)
            {
                ans[i] = temp[i];
            }
            swap(n, m);
            /* for (int i = 1; i <= n * m; i++)
            {
                cout << ans[i] << " ";
                if (i % m == 0)
                {
                    cout << endl;
                }
            }
            // cout << endl; */
        }
        else if (op == 3)
        {
            /* for (int i = 1; i <= n * m; i++)
            {
                cout << ans[i] << " ";
                if (i % m == 0)
                {
                    cout << endl;
                }
            } */
            // cout << endl;
            int x = a * m + b + 1;
            cout << ans[x] << endl;
        }
    }
}